﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace Maticsoft.Web.ActionInfo
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int ActionId=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(ActionId);
				}
			}
		}
			
	private void ShowInfo(int ActionId)
	{
		Maticsoft.BLL.ActionInfo bll=new Maticsoft.BLL.ActionInfo();
		Maticsoft.Model.ActionInfo model=bll.GetModel(ActionId);
		this.lblActionId.Text=model.ActionId.ToString();
		this.txtActionCodeName.Text=model.ActionCodeName;
		this.txtActionName.Text=model.ActionName;
		this.txtActionPage.Text=model.ActionPage;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtActionCodeName.Text.Trim().Length==0)
			{
				strErr+="ActionCodeName不能为空！\\n";	
			}
			if(this.txtActionName.Text.Trim().Length==0)
			{
				strErr+="ActionName不能为空！\\n";	
			}
			if(this.txtActionPage.Text.Trim().Length==0)
			{
				strErr+="ActionPage不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int ActionId=int.Parse(this.lblActionId.Text);
			string ActionCodeName=this.txtActionCodeName.Text;
			string ActionName=this.txtActionName.Text;
			string ActionPage=this.txtActionPage.Text;


			Maticsoft.Model.ActionInfo model=new Maticsoft.Model.ActionInfo();
			model.ActionId=ActionId;
			model.ActionCodeName=ActionCodeName;
			model.ActionName=ActionName;
			model.ActionPage=ActionPage;

			Maticsoft.BLL.ActionInfo bll=new Maticsoft.BLL.ActionInfo();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
